import type { OptionProps, PicLink, PicTitleDescStatus, TextProps } from '@/types'
import { isPicTitleDescStatusArr, isPLink, isStringStatusArr } from '@/types'

export const setTextPropsStatus = (textProps: TextProps, status: string) => {
  textProps.status = status
}

export const addStringArrStatus = (optionsProps: OptionProps, status: string) => {
  if (isStringStatusArr(optionsProps.status)) {
    optionsProps.status.push(status)
  }
}

export const removeOptionsArrStatus = (optionsProps: OptionProps, num: number) => {
  optionsProps.status.splice(num, 1)
}

export const setCurrentStatus = (optionProps: OptionProps, num: number) => {
  optionProps.currentStatus = num
}

export const setPicImageStatus = (optionProps: OptionProps, picLink: PicLink) => {
  if (isPicTitleDescStatusArr(optionProps.status)) {
    optionProps.status[picLink.index].value = picLink.link
  }
}

export const addOptionsStatus = (optionProps: OptionProps, payLoad: PicTitleDescStatus) => {
  if (isPicTitleDescStatusArr(optionProps.status)) {
    optionProps.status = [...optionProps.status, payLoad]
  }
}

export const setOptionsisUserStatus = (optionProps: OptionProps, isUser: boolean) => {
  optionProps.isUse = isUser
}
